<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>商品管理</title>
    <%@include file="/pages/common/head.jsp" %>
</head>
<script>
    $(function () {
        $("a.deleteclass").click(function () {
            return confirm("您确认要删除【" + $(this).parent().parent().find("td:first").text() + "】？");
        });
    });
</script>

<body>

<div id="header">
    <img class="logo_img" alt="" src="static/img/logo.gif">
    <span class="wel_word">商品管理系统</span>
</div>

<c:if test="${sessionScope.jiaoyan!='dhxamxy'}">
    <td>对不起，您无权访问！</td>
</c:if>
<c:if test="${sessionScope.jiaoyan=='dhxamxy'}">
    <form action="UpLoadServet" method="post" enctype="multipart/form-data">
        上传文件：<input type="file" name="spicture"><br><br>
        <input type="submit" value="上传"><br><br>
    </form>
    <div id="main">
        <table>
            <tr>
                <td>名称</td>
                <td>id</td>
                <td>价格</td>
                <td>类别</td>
                <td>图片地址</td>
                <td colspan="2">操作</td>
            </tr>

            <c:forEach items="${requestScope.foods}" var="book">
                <tr>
                    <td>${book.name}</td>
                    <td>${book.id}</td>
                    <td>${book.price}</td>
                    <td>${book.cate}</td>
                    <td>${book.imgpath}</td>
                    <td><a class="deleteclass" href="adminServlet?action=delete&id=${book.id}">删除</a></td>
                </tr>
            </c:forEach>

            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td><a href="pages/manager/book_edit.jsp">添加商品</a></td>
            </tr>
        </table>
    </div>

    <div id="main">
        <table>
            <tr>
                <td>时间</td>
                <td>宿舍号</td>
                <td>商品名称</td>
            </tr>

            <c:forEach items="${requestScope.callfoods}" var="book">
                <tr>
                    <td>${book.time}</td>
                    <td>${book.sushehao}</td>
                    <td>${book.foodname}</td>
                </tr>
            </c:forEach>
        </table>
    </div>

</c:if>
</body>
</html>